//
//  ZYCLectureRecordStatisticsCell.m
//  ZDSC
//
//  Created by ZDTX on 2021/7/23.
//

#import "ZYCLectureRecordStatisticsCell.h"
#import "ZYCTourStatisticsModel.h"
#import "NSDateExtra.h"
@interface ZYCLectureRecordStatisticsCell ()
//班级类型
@property (nonatomic, strong) UILabel *titleLabel;
//授课次数
@property (nonatomic, strong) UILabel *lecturesNumLabel;
@property (nonatomic, strong) UILabel *line;
// 课程类型
@property (nonatomic, strong) UILabel *genreLabel;
// 所属课程
@property (nonatomic, strong) UILabel *sortLabel;
// 授课老师
@property (nonatomic, strong) UILabel *teacherLabel;
// 有效日期
@property (nonatomic, strong) UILabel *effectiveDateLabel;
// 计划节数
@property (nonatomic, strong) UILabel *planNumLabel;
// 地点
@property (nonatomic, strong) UILabel *addressLabel;


@end
@implementation ZYCLectureRecordStatisticsCell
- (void)setModel:(ZYCTourStatisticsModel *)model{
    _model = model;
    _titleLabel.text = model.className;
    _lecturesNumLabel.text = [NSString stringWithFormat:@"授课次数:%@",model.checkCountMsg];
    _genreLabel.text = [NSString stringWithFormat:@"课程类型:%@",model.courseTypeName];
    _sortLabel.text = [NSString stringWithFormat:@"所属课程:%@",model.courseName];;
    _teacherLabel.text = [NSString stringWithFormat:@"授课老师:%@",model.teacherName];
    NSString *startTime = [NSString stringWithFormat:@"%@", [NSDateExtra getDateStringWithDateString:model.startDate currenDateFormat:@"yyyy-MM-dd" dateFormat:@"yyyy/MM/dd"]];
    NSString *endTime = [NSString stringWithFormat:@"%@", [NSDateExtra getDateStringWithDateString:model.endDate currenDateFormat:@"yyyy-MM-dd" dateFormat:@"yyyy/MM/dd"]];
    _effectiveDateLabel.text =  [NSString stringWithFormat:@"授课有效日期:%@-%@",startTime,endTime];
    _planNumLabel.text = [NSString stringWithFormat:@"计划节次:%@次",model.planSection];
    _addressLabel.text = [NSString stringWithFormat:@"授课地点:%@",model.courseAddress];
}


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self.contentView addSubview:self.titleLabel];
        [self.contentView addSubview:self.lecturesNumLabel];
        [self.contentView addSubview:self.line];
        [self.contentView addSubview:self.genreLabel];
        [self.contentView addSubview:self.sortLabel];
        [self.contentView addSubview:self.teacherLabel];
        [self.contentView addSubview:self.effectiveDateLabel];
        [self.contentView addSubview:self.planNumLabel];
        [self.contentView addSubview:self.addressLabel];
        
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.top.equalTo(self.contentView).offset(20.0f);
        }];
        
        [self.lecturesNumLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.contentView).offset(-20.0f);
            make.centerY.equalTo(self.titleLabel);
        }];
        
        [self.line mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView).offset(9.5f);
            make.right.equalTo(self.contentView).offset(-9.5f);
            make.top.equalTo(self.titleLabel.mas_bottom).offset(17.0f);
            make.height.mas_equalTo(1.0f);
        }];
        
        [self.genreLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.line.mas_bottom).offset(15.0f);
            make.left.equalTo(self.titleLabel);
        }];
        [self.sortLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.genreLabel.mas_bottom).offset(14.0f);
            make.left.equalTo(self.titleLabel);
        }];
        [self.teacherLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.sortLabel.mas_bottom).offset(14.0f);
            make.left.equalTo(self.titleLabel);
        }];
        
        [self.effectiveDateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.teacherLabel.mas_bottom).offset(14.0f);
            make.left.equalTo(self.titleLabel);
        }];
        
        [self.planNumLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.effectiveDateLabel.mas_bottom).offset(14.0f);
            make.left.equalTo(self.titleLabel);
        }];
        [self.addressLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.planNumLabel.mas_bottom).offset(14.0f);
            make.left.equalTo(self.titleLabel);
            make.bottom.equalTo(self.contentView).offset(-20.0f);
        }];
    }
    return self;
}

- (UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [UILabel LabelWithFont:kSystemBoldFont(17.0f) titleColor:HEX_RGB(@"#262A28") textAlignment:ZZTextAlignmentLeft];
    }
    return _titleLabel;
}

- (UILabel *)lecturesNumLabel {
    if (!_lecturesNumLabel) {
        _lecturesNumLabel = [UILabel LabelWithFont:kCustomFont(@"PingFangSC-Regular", 14.0f) titleColor:HEX_RGB(@"#2B302D") textAlignment:ZZTextAlignmentLeft];
    }
    return _lecturesNumLabel;
}
- (UILabel *)line {
    if (!_line) {
        _line = [[UILabel alloc] init];
        _line.backgroundColor = HEX_RGB(@"#EAEAEA");
    }
    return _line;
}

- (UILabel *)genreLabel {
    if (!_genreLabel) {
        _genreLabel = [UILabel LabelWithFont:kCustomFont(@"PingFangSC-Light", 14.0f) titleColor:HEX_RGB(@"#888888") textAlignment:ZZTextAlignmentLeft];
    }
    return _genreLabel;
}

- (UILabel *)sortLabel {
    if (!_sortLabel) {
        _sortLabel = [UILabel LabelWithFont:kCustomFont(@"PingFangSC-Light", 14.0f) titleColor:HEX_RGB(@"#888888") textAlignment:ZZTextAlignmentLeft];
    }
    return _sortLabel;
}

- (UILabel *)teacherLabel {
    if (!_teacherLabel) {
        _teacherLabel  = [UILabel LabelWithFont:kCustomFont(@"PingFangSC-Light", 14.0f) titleColor:HEX_RGB(@"#888888") textAlignment:ZZTextAlignmentLeft];
    }
    return _teacherLabel;
}

- (UILabel *)effectiveDateLabel {
    if (!_effectiveDateLabel) {
        _effectiveDateLabel  = [UILabel LabelWithFont:kCustomFont(@"PingFangSC-Light", 14.0f) titleColor:HEX_RGB(@"#888888") textAlignment:ZZTextAlignmentLeft];
    }
    return _effectiveDateLabel;
}

- (UILabel *)planNumLabel {
    if (!_planNumLabel) {
        _planNumLabel  = [UILabel LabelWithFont:kCustomFont(@"PingFangSC-Light", 14.0f) titleColor:HEX_RGB(@"#888888") textAlignment:ZZTextAlignmentLeft];
    }
    return _planNumLabel;
}

- (UILabel *)addressLabel {
    if (!_addressLabel) {
        _addressLabel = [UILabel LabelWithFont:kCustomFont(@"PingFangSC-Light", 14.0f) titleColor:HEX_RGB(@"#888888") textAlignment:ZZTextAlignmentLeft];
    }
    return _addressLabel;
}



@end
